<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2022/12/12
 * Time: 18:22
 */

namespace app\api\controller;

use think\Db;

class Giftbanner extends Base
{
    private $user_id;
    /**
     * 异地登录验证
     * @return string
     */
    public function __construct()
    {
        $this->user_id = input('user_id');
        $time = input('time');
        $value = input('value');
        $reqKey = input('reqKey');
        $auth = $this->checkAll($this->user_id, $time, $value, $reqKey);
        if($auth == 112){
            echo json_encode(['status' => 301, 'msg' => $this->otherLogin]);
            exit;
        }elseif($auth == 110){
            echo json_encode(['status' => 302, 'msg' => $this->frost]);
            exit;
        }elseif($auth == 2111){
            echo json_encode(['status' => 303, 'msg' => $this->del]);
            exit;
        }
    }

    /**
     * 轮播图
     * @return \think\response\Json
     */
    public function bannerList(){
        $banner = Db::table('up_bo_giftbag_banner')
            ->where('banner_status', 1)
            ->field('banner_id, banner_image')
            ->order('banner_sort desc')
            ->select();
        if($banner){
            return json(['status' => 200, 'msg' => $banner]);
        }else{
            return json(['status' => 200, 'msg' => []]);
        }
    }

    /**
     * 轮播图详情
     * banner_id     轮播图ID
     * @return \think\response\Json
     */
    public function bannerDetail(){
        $banner_id = input('banner_id');
        $detail = Db::table('up_bo_giftbag_banner')->where('banner_id', $banner_id)->value('banner_content');
        return json(['status' => 200, 'msg' => $detail]);
    }
}